  <?php
include('../config/DBConnect.php');
include '../template/header.php';
include '../template/menuleft.php';
include '../template/menuright.php';
?>
 
   <div class="viewct" >
	<center><form action="timkiem.php" method="post">
    	<label>Nhập mã sinh viên:</label><input type="text" name="keyword" placeholder="--Mã sinh viên--" />
        <input type="submit" value="Tìm"  name="ok" />  </form></center>
   <div class="title" style="font-size:18px; margin-top:50px;"><b>Danh Sách Tìm Được</b></div> 
   <div class="tb">
           <table border="1" cellpadding="0" cellspacing="0" style="font-size:12px; font-family:Arial, Helvetica, sans-serif;">
               <tbody>
               <tr><th >STT</th><th>Mã SV</th><th>Họ Tên</th>
                   <th>Ngày Sinh</th><th>Giới Tính</th><th>Lớp</th>
                   <th>Khoa</th><th>Mã Phòng</th></tr> 

<?php
	if(isset( $_POST['ok']))
	{
	$ma=$_POST['keyword'];
	$sql_getall="select * from sinhvien join sinhvien_phong on sinhvien.masv=sinhvien_phong.masv where sinhvien.masv=".$ma;
	$r=mysql_query($sql_getall);	
				 	$i=0;
					if (mysql_num_rows($r)>0)
					{					
						while($nr=mysql_fetch_array($r))
						{
						
						$i++;
						if ($i%2==0)
						{
							
				 ?>                 
                <tr style="background:#FFC;">
                	<td> <?php echo $i;?></td>
                    <td class="style1" >
             		<?php echo $nr['masv']; ?></td>
                    <td ><?php echo $nr['hoten'];?></td>
                    <td><?php echo $nr['ngaysinh'];?></td>
                    <td><?php if ($nr['gioitinh']==0 ){echo"Nữ";}else {echo "Nam";} ?></td>
                    <td><?php echo $nr['lop'];?></td>
                    <td><?php echo $nr['khoa'];?></td>
                    <td><?php echo $nr['maphong'];?></td>                                                   
                </tr>
               
               <?php }else
			   			{
							?>
				<tr style=" background:#CCC;">
                    <td> <?php echo $i;?></td>
                    <td class="style1" >
                    <?php echo $nr['masv']; ?></td>
                    <td ><?php echo $nr['hoten'];?></td>
                    <td><?php echo $nr['ngaysinh'];?></td>
                    <td><?php if ($nr['gioitinh']==0 ){echo"Nữ";}else {echo "Nam";} ?></td>
                    <td><?php echo $nr['lop'];?></td>
                    <td><?php echo $nr['khoa'];?></td>
                    <td><?php echo $nr['maphong'];?></td>                                                  
                </tr>
                <?php
						}
			   			
					}
				}else
				{
					echo"Không tìm thấy sinh viên nào!";
				}
	}
					?>
              </tbody>
           </table> 
           </div>    
  </div>
   
 
<?php include '../template/footer.php';?>                                			